#include<stdio.h>
int countdigit(int number,int digit)
{
	int sum = 0;
	while(number!=0)
{
	if(digit==number%10)
	{
		
		sum++;
	}
	number = number/10;
}
	return sum;
} 
int main()
{
	
	int number,digit,sum;
	scanf("%d %d",&number,&digit);
	int u =	 countdigit(number,digit);
	printf("%d",u);
	return 0;
}
